import Vue from "vue";
import Router from "vue-router";
// import Login from '@/views/login/index.vue';
// 在下面↓的情况下，浏览器会默认地导入../views/login目录下面的index.vue组件
import Login from '../views/login';
import Layout from '@/components/Layout'; // “Layout.vue”中的“.vue”可以舍去不写
import Home from '../views/home';
import Goods from '../views/goods';
import Staff from '../views/staff';
import Supplier from '../views/supplier';
import Customer from '../views/customer';
Vue.use(Router);

export default new Router({
  mode:'history',
  routes:[
    {
      path:'/login',
      name:'login', //路由的名称
      component:Login //组件名（组件对象）
    },
    {
      path:'/',
      name:'layout', //路由的名称
      component:Layout, //组件名（组件对象） // “Layout”的含义是“布局”
      redirect:'/home',
      children:[
        {
          path:'/home',
          component:Home,
          meta:{title:'首页'}
        },
        // {
        //   path:'/goods',
        //   component:Goods
        // }
      ]
    },
    {
      path:'/goods',
      component:Layout,
      children:[
        {
          path:'/', // 注意：此处等价于'/goods/'
          component:Goods,
          meta:{title:'商品管理'}
        }
      ]
    },
    {
      path:'/staff',
      component:Layout,
      children:[
        {
          path:'/', // 注意：此处等价于'/staff/'
          component:Staff,
          meta:{title:'员工管理'}
        }
      ]
    },
    {
      path:'/supplier',
      component:Layout,
      children:[
        {
          path:'/', // 注意：此处等价于'/supplier/'
          component:Supplier,
          meta:{title:'供应商管理'}
        }
      ]
    },
    {
      path:'/customer',
      component:Layout,
      children:[
        {
          path:'/', // 注意：此处等价于'/customer/'
          component:Customer,
          meta:{title:'客户管理'}
        }
      ]
    }
  ]
});
